#include <iostream>
#include <cstdlib>
#include <string>

int main() 
{
    const char* envLocale = std::getenv("LC_CTYPE");
    if (envLocale == nullptr) {
        std::cerr << "Failed to get the LC_CTYPE environment variable." << std::endl;
        return 1;
    }
    std::string localeStr(envLocale);
    std::cout << "LC_CTYPE environment variable: " << localeStr << std::endl;

    size_t dotPos = localeStr.find('.');
    if (dotPos!= std::string::npos) {
        std::string charset = localeStr.substr(dotPos + 1);
        std::cout << "Current encoding set: " << charset << std::endl;
    } else {
        std::cout << "No encoding set found in the LC_CTYPE environment variable." << std::endl;
    }

    return 0;
}
